package com.codeoss.module.stock.service.impl;

import java.math.BigDecimal;
import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.codeoss.framework.service.impl.BaseService;
import com.codeoss.module.stock.dao.StockInConfirmLineMapper;
import com.codeoss.module.stock.model.StockInConfirm;
import com.codeoss.module.stock.model.StockInConfirmLine;
import com.codeoss.module.stock.model.StockInLine;
import com.codeoss.module.stock.service.IStockInConfirmLineService;

@Service
public class StockInConfirmLineService extends BaseService<StockInConfirmLineMapper, StockInConfirmLine>
		implements IStockInConfirmLineService {

	@Override
	@Transactional
	public StockInConfirmLine createConfirmLine(StockInConfirm stockInConfirm, StockInLine stockInLine) {
		// TODO Auto-generated method stub
		StockInConfirmLine stockInConfirmLine=new StockInConfirmLine();
		stockInConfirmLine.setProductProductId(stockInLine.getProductProductId());
		stockInConfirmLine.setProductAttrSetInstanceId(stockInLine.getProductAttrSetInstanceId());
		stockInConfirmLine.setUomUomId(stockInLine.getUomUomId());
		stockInConfirmLine.setStockInConfirmId(stockInConfirm.getId());
		stockInConfirmLine.setStockInLineId(stockInLine.getId());
		stockInConfirmLine.setTargetQty(stockInLine.getQtyEntered());
		stockInConfirmLine.setConfirmedQty(stockInLine.getQtyEntered());
		stockInConfirmLine.setScrappedQty(new BigDecimal(0));
		insert(stockInConfirmLine);
		return stockInConfirmLine;
	}

	@Override
	public List<StockInConfirmLine> getLineListByStockInConfirmId(Long stockInConfirmId) {
		// TODO Auto-generated method stub
		QueryWrapper<StockInConfirmLine> query=new QueryWrapper<StockInConfirmLine>();
		query.eq("stock_in_confirm_id", stockInConfirmId);
		return list(query);
	}
}